package bancoperu.rest;


import java.util.Collection;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import net.sf.json.JSONArray;
import bancoperu.dao.CustomerDAO;
import bancoperu.model.Customer;

@Path("/customers")
public class CustomersRest {

	@GET
	@Produces(MediaType.TEXT_PLAIN)
	public String getAllCustomers() {		
		
		JSONArray array = new JSONArray();
		
		try {
			CustomerDAO dao = new CustomerDAO();
			Collection<Customer> customers = dao.getAllCustomers();		
			
			array.addAll(customers);
			
		} catch (Exception e) {	
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
		return array.toString();
	}
	
}
